package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.WantedBook;
import com.pgybook.db.entity.domain.WantedBookEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface WantedBookMapper {
    int countByExample(WantedBookEx example);

    int deleteByExample(WantedBookEx example);

    @Delete({
            "delete from wantedbook",
            "where WBID = #{wbid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long wbid);

    @Insert({
            "insert into wantedbook (BOOKID, CUSTID, ",
            "LIBID, CRTTIME)",
            "values (#{bookid,jdbcType=BIGINT}, #{custid,jdbcType=BIGINT}, ",
            "#{libid,jdbcType=INTEGER}, #{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "wbid", before = false, resultType = Long.class)
    int insert(WantedBook record);

    int insertSelective(WantedBook record);

    List<WantedBook> selectByExample(WantedBookEx example);

    @Select({
            "select",
            "WBID, BOOKID, CUSTID, LIBID, CRTTIME",
            "from wantedbook",
            "where WBID = #{wbid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    WantedBook selectByPrimaryKey(Long wbid);

    int updateByExampleSelective(@Param("record") WantedBook record, @Param("example") WantedBookEx example);

    int updateByExample(@Param("record") WantedBook record, @Param("example") WantedBookEx example);

    int updateByPrimaryKeySelective(WantedBook record);

    @Update({
            "update wantedbook",
            "set BOOKID = #{bookid,jdbcType=BIGINT},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "LIBID = #{libid,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where WBID = #{wbid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(WantedBook record);
}
